﻿using D3StatsClient.Model;
using D3StatsClient.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace D3StatsClient.View
{
    /// <summary>
    /// Interaction logic for NewSessionWindow.xaml
    /// </summary>
    public partial class NewSessionWindow
    {
        public NewSessionWindow()
        {
            InitializeComponent();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Button button = (Button)sender;

            var vm = ViewModelManager<MainWindowViewModel>.ViewModel;

            string sessionName = button.Tag.ToString();

            vm.provider = new XMLStatsProvider(this.Dispatcher);

            vm.provider.OpenConnection(sessionName);
            vm.SessionName = sessionName;

            vm.IsSessionLoaded = true;
            vm.IsContinuedSession = false;

            vm.ReloadLoadUIData();

            //Push notifications or records to UI
            (vm.provider as XMLStatsProvider).XMLData.Changed += vm.XMLData_Changed;

            this.Close();
        }
    }
}
